package br.edu.infnet.manageBean;



import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import br.edu.infnet.dao.AlunoDao;
import br.edu.infnet.modelo.Aluno;

@ManagedBean
@SessionScoped
public class AlunoBean implements Serializable {
	
	
	private static final long serialVersionUID = 1988377827335921632L;
	private Aluno aluno;
	private List<Aluno> listaAlunos;
	private boolean loggedIn;
	
	

	public boolean isLoggedBean() {
		return loggedIn;
	}

	public void setLoggedBean(boolean loggedBean) {
		this.loggedIn = loggedBean;
	}

	public AlunoBean() {
		this.aluno = new Aluno();
		listaAlunos = new ArrayList<Aluno>();
		listaAlunos = new AlunoDao().listarAlunos();
	}
	
	public List<Aluno> getListaAlunos() {
		return listaAlunos;
	}

	public void setListaAlunos(List<Aluno> listaAlunos) {
		this.listaAlunos = listaAlunos;
	}




	public Aluno getAluno() {
		return aluno;
	}

	public void setAluno(Aluno aluno) {
		this.aluno = aluno;
	}
	
	
	public String efeluarLogin(){
		if(new AlunoDao().validar(aluno)){
			loggedIn= true;
			FacesContext.getCurrentInstance().getExternalContext().getSession(loggedIn);
			return "avaliacao";
		}
		return "index";
		
	}
	
	public String cadastrar(){
		return "cadastroAluno";	
	}
	
	public void salvar(){
		System.out.println(aluno.getNome());
	}
	
	
	
	
	
}
